home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
PET
/
S-Super PET
/
(s)tk.d64
/
ADUMP.ASM
< prev
next >
Wrap
Assembly Source File
|
2009-01-18
|
6KB
|
124 lines
;mainline routine adump ~ dumps all contents of file to printer
;this dump loads in Bank 15, and is loaded from main menu. Written by Reg Beck;
;modified by D.B. to output to all printers and for extra LF if wanted
xref initstd_,openf_,fgetchar_,fputchar_,eof_,closef_,tbreak_,putnl_
xref display, delay, read16, printf_, fputnl_
service_ equ $32
kyputb_ equ $dd82
jsr initstd_ ;initialize standard I/O
jsr putnl_ ;move cursor down one line
;***modified code for extra linefeed
ldd #extralf ;do we want an extra linefeed for printer?
jsr printf_
loop ;stay in this loop until a yes/no answer
jsr kyputb_ ;is given
cmpb #'y
if eq ;if it's yes, set control 'linefd' to zero
clr linefd
jmp outt
endif
cmpb #'n ;otherwise, quit
quif eq
endloop
;***modified code for printer type
outt ldd #which ;prompt for printer type
jsr printf_
loop ;stay in loop until you get a valid
jsr kyputb_ ;printer response
cmpb #'p ;this loop stuck in by D.B. to handle
if eq ;all printer types
ldd #$b129 ;address of 'printer' in ROM
jmp gotit
endif
cmpb #'i
if eq
ldd #ieee ;address of 'ieee4' in this program
jmp gotit
endif
cmpb #'s
if eq
ldd #$b144 ;address of 'serial' in ROM
jmp gotit
endif
endloop
gotit std outfile ;end mod code**
ldx #prompt ;load prompt message
jsr display ;display prompt
jsr putnl_ ;move cursor down one line
ldx #infile ;load address of input file name buffer
jsr read16 ;read in input file name
ldx #mode1 ;load address of input file mode
pshs x ;push file mode onto stack
ldd #infile ;load address of input file name
jsr openf_ ;open input file
std inptr ;store input file control block address
puls x ;clean up stack
if ne ;if file opened then continue
ldx #mode2 ; load address of output file mode
pshs x ; push onto stack
ldd outfile ; load address of output file name
jsr openf_ ; open output file
std outptr ; store output file control block address
puls x ; clean up stack
loop ; loop
ldd inptr ; load input file control block
jsr fgetchar_ ; get character from file
pshs d ; push character on stack
cmpb #$d ; is it a carriage return?
if eq ; if so,
tst linefd ; do we want an extra linefeed?
bne skip ; if we don't, forget it.
ldd outptr ; otherwise, give one
jsr fputnl_
endif
skip jsr delay ; let I/O bus settle
ldd outptr ; load output file control block
jsr fputchar_ ; send character to printer
puls d ; clean up stack
ldd inptr ; load input file control block
jsr eof_ ; check for end of file
until ne ; quit if end of file
ldd outptr ; load output file control block
jsr closef_ ; close output file
ldd inptr ; load input file control block
jsr closef_ ; close input file
else ;else
ldx #errmsg1 ; load address of error message 1
jsr display ; display error message 1
jsr putnl_ ; line feed and carriage return
ldx #errmsg2 ; load address of error message 2
jsr display ; display error message 2
jsr putnl_ ; line feed and carriage return
loop ; loop
jsr tbreak_ ; has stop key been pressed?
until ne ; quit if yes
endif ;endif
clr service_ ;clear service_ (to return to menu)
rts ;return 6809 menu
linefd fcb 1
outfile rmb 2 ;storage for printer type
ieee fcc "ieee4" ;mod by D.B. for use with all printers.
fcb 0
mode1 fcc "r"
fcb 0
mode2 fcc "w"
fcb 0
inptr rmb 2
outptr rmb 2
bufend rmb 2
infile rmb 17
errmsg1 fcc "open disk error"
fcb 0
errmsg2 fcc "press stop key to return to menu"
fcb 0
prompt fcc "enter file name--maximum of 16 characters"
fcb 0
extralf fcc "%nneed an extra linefeed for your printer? y or n:%n%n"
fcb 0
which fcc "enter 'i' for ieee4, 's' for serial, or 'p' for printer%n%n"
fcb 0 ;mod by D.B. for use with all printers.
end